<?php 
header("Content-type:text/html;charset=utf-8");
require_once('usermodel.php');
require_once('controller.php');
class usercontroller extends controller{ 
	function __construct(){
		parent::__construct();
	}

	function listusers(){
	$usermodel=new usermodel();
	$data = $usermodel->getuserlist();
	//var_dump($data);
	//include "user/userlist.php";
	//include "user/listusers.php";
	$this->assign('user',$data);
	$this->display();
}
	function userform(){
		include "user/userform.php";
	}
	function adduser(){
		//获取表单数据
		$data = $_POST;
		
		//调用model中的adduser的方法，添加到数据库
		$model = new usermodel();
		$result = $model->adduser($data);
		//var_dump($data);
		//如果成功，输出，转到列表页面
		if($result){
			echo "成功".'<a href="ind.php?c=user&m=listusers">回到视频列表</a>';
		}
		else {echo "失败"; }
	}
	function useredit(){
		//echo $_GET['id'];
		$usereditmodel=new usermodel();
		$data = $usereditmodel->getuserbyid($_GET['id']);
		//var_dump($data);
		include "user/useredit.php";
	}
	function updateuser(){
		$data = $_POST;
		//var_dump($data);
		$usermodel = new usermodel();
		$result = $usermodel->updateuser($data);
		if($result){
			echo "成功".'<a href="ind.php?c=user&m=listusers">回到视频列表</a>';
		} else 
		{
			echo "失败";
		}
	}
	function deluser(){
		$id = $_GET['id'];
		//var_dump($data);
		$model = new usermodel();
		$result = $model->deluser($id);
			if($result){
			echo "成功".'<a href="ind.php?c=user&m=listusers">回到视频列表</a>';
		} else 
		{
			echo "失败";
		}
		



	}



}



 ?>